import java.util.Scanner;

public class ArrayGradesTest {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        System.out.print("Input the number of students:");
        int stu_num = sc.nextInt();
        int[] grades = new int[stu_num];
        char[] level = new char[stu_num];
        System.out.println("Input students' grades:");
        int highest = 0;
        int highest_idx = 0;
        for (int i = 0; i < stu_num; i++) {
            grades[i] = sc.nextInt();
            if(grades[i] >= highest){
                highest = grades[i];
                highest_idx = i;
            }
        }
        for (int i = 0; i < stu_num; i++) {
            if(highest - grades[i] <= 10){
                level[i] = 'A';
            } else if (highest - grades[i] <= 20 && highest - grades[i] >= 10) {
                level[i] = 'B';
            } else if (highest - grades[i] <= 30 && highest - grades[i] >= 20) {
                level[i] = 'C';
            } else {
                level[i] = 'D';
            }
        }
        System.out.println("The highest student is:" + highest_idx + "\tGrade is:" + grades[highest_idx]);
        System.out.println("The students with their grades and their level as follow:\n");
        System.out.println("idx\tgrades\tlevel");
        for (int i = 0; i < stu_num; i++) {
            System.out.println(i + "\t" + grades[i] + "\t" + level[i]);
        }
    }
}
